package xyz.scootaloo.oj.leetcode

import cn.hutool.core.lang.Console
import org.junit.Test

/**
 * @author flutterdash@qq.com
 * @since 2021/4/29 17:39
 */
class P190 {

    fun reverseBits(n: Int): Int {
        var number = n
        var res = 1

        for (count in 1..32) {
            val flag = number and 1
            number = number.ushr(1)
            res = if (flag == 1)
                (res shl 1) + 1
            else
                res shl 1
        }

        return res
    }

    @Test
    fun test0() {
        Console.log(reverseBits(43261596))
        Console.log(reverseBits(4294967293.toInt()))
        Console.log(reverseBits(3221225471.toInt()))
    }

}
